package com.example.demo.controller;

import com.example.demo.Entity.Item;
import com.example.demo.Service.ContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/content")
public class ContentController {

    private final ContentService contentService;

    @Autowired
    public ContentController(ContentService contentService) {
        this.contentService = contentService;
    }

    /**
     * 获取指定类型的内容列表。
     *
     * @param type 内容类型。.
     *
     * @return 包含内容项的列表。
     */
    @GetMapping("/{type}")
    public List<Item> getContentByType(@PathVariable String type) {
        System.out.println(type);
        System.out.println(contentService.getContentByType(type));
        return contentService.getContentByType(type);
    }
}